import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2024-11-02
 * Time:23:02
 */
class MyQueue1 {
    private Stack<Integer> s1;
    private Stack<Integer> s2;
    public MyQueue1() {
        s1=new Stack<>();
        s2=new Stack<>();
    }

    public void push(int x) {
        s1.push(x);
    }
//出的时候统一出s2的
    public int pop() {
        if(empty()){
            return 0;
        }
        if(s2.isEmpty()){
            while (!s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.pop();
    }

    public int peek() {
        if(empty()){
            return 0;
        }
        if(s2.isEmpty()){
            while (!s1.isEmpty()){
                s2.push(s1.pop());
            }
        }
        return s2.peek();
    }

    public boolean empty() {
        return s1.isEmpty()&&s2.isEmpty();
    }
}
